package com.teach.shape3;

import java.util.Scanner;

/**
 * 长方形
 * jlzhou.top 版权所有
 * @author J.L.Zhou 
 * 
 */
public class Trilateral extends AbstractShape {
	
	public Trilateral(){
		this.name = "三角形";
	}

	/**
	 * 边一
	 */
	private float border1;
	/**
	 * 边二
	 */
	private float border2;
	/**
	 * 边三
	 */
	private float border3;

	public void input(Scanner sc) {
	
		System.out.println("输入" + name + "的三边: ");
		border1 = sc.nextFloat();
		border2 = sc.nextFloat();
		border3 = sc.nextFloat();
		boolean flag = border1 + border2 > border3 && border1 + border3 > border2 && border2 + border3 > border1;
		if (!flag) {
			System.out.println("您输入的三边不能构成" + name);
			input(sc);// 递归调用
		}
	}

	public float getBorder1() {
		return border1;
	}

	public void setBorder1(float border1) {
		this.border1 = border1;
	}

	public float getBorder2() {
		return border2;
	}

	public void setBorder2(float border2) {
		this.border2 = border2;
	}

	public float getBorder3() {
		return border3;
	}

	public void setBorder3(float border3) {
		this.border3 = border3;
	}

	@Override
	public void calculate() {
		perimeter = border1 + border2 + border3;
		float s = perimeter / 2;
		area = (float) Math.sqrt(s * (s - border1) * (s - border2) * (s - border3));
	}

	@Override
	public String getInputInfo() {
		return String.format("三边：%.2f,%.2f,%.2f", border1, border2,border3);
	}

}
